package com.tts.dede;

import java.util.Random;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;

public class Fruit {
	
	
	private int x, y;
	private Bitmap bmp;
	private Random rand = new Random();
	private int size = 50;
	
	public Fruit(Context myContext, Canvas canvas) {
		//x = (int)(Math.random()*100%canvas.getWidth());	
		x = rand.nextInt(canvas.getWidth()-(size+1));
		System.out.println("Random int :" + x);
		y = 0;
		switch(rand.nextInt(6)) {// prend une image de fruit sur les 5 aux hazards
		case 0:
			bmp = BitmapFactory.decodeResource(myContext.getResources(), R.drawable.banana);	
			break;
		case 1:
			bmp = BitmapFactory.decodeResource(myContext.getResources(), R.drawable.peach);	
			break;
		case 2:
			bmp = BitmapFactory.decodeResource(myContext.getResources(), R.drawable.orange);	
			break;
		case 3:
			bmp = BitmapFactory.decodeResource(myContext.getResources(), R.drawable.pear);	
			break;
		case 4:
			bmp = BitmapFactory.decodeResource(myContext.getResources(), R.drawable.apple);	
			break;
		case 5:
			bmp = BitmapFactory.decodeResource(myContext.getResources(), R.drawable.melon);	
			break;
		default:
			bmp = BitmapFactory.decodeResource(myContext.getResources(), R.drawable.banana);
			break;			
		}			
		bmp = Bitmap.createScaledBitmap(bmp, size, size, true);
	}
	
	public int getX() {
		return x;
	}


	public void setX(int x) {
		this.x = x;
	}


	public int getY() {
		return y;
	}


	public void setY(int y) {
		this.y = y;
	}

	public Bitmap getBmp() {
		return bmp;
	}
	
	public void  moveDown() {
		this.y += 3;
	}

	public int getSize() {
		return size;
	}

	public void setSize(int size) {
		this.size = size;
	}



}
